package com.google.code.alpaca.prototype.server;

import com.google.code.alpaca.prototype.dao.DAOMapping;
import com.google.code.alpaca.prototype.dao.MessageDAO;
import com.google.code.alpaca.prototype.dao.impl.DefaultDAOMapping;
import com.google.inject.AbstractModule;

public class DAOConfigModule extends AbstractModule {

	@Override
	protected void configure() {
		bind(DAOMapping.class).to(DefaultDAOMapping.class);

		bindDAO(MessageDAO.class);

		requestStaticInjection(DAOProvider.class);
	}

	private <T> void bindDAO(Class<T> aDaoType) {
		bind(aDaoType).toProvider(new DAOProvider<T>(aDaoType));
	}

}
